<?Lassoscript
// Last modified 4/17/09 by Eric Landmann

// DEVELOPER'S NOTES
// The assumption is that the filename will be named on disk the same as the MemberID
// Therefore, no database entry is needed as we know the MemberID from the login

// CHANGE NOTES
// 4/17/09
// Version 1.0

Include:'siteconfig.lasso';
Var:'vPage_Title' = (($svSiteCommonName)' Forums');

Include:($svLibsPath)'page_header.inc';

// Start the Session
Include:($svLibsPath)'sessions.inc'; 
Include:($svLibsPath)'header2.inc'; 

// Debugging
// Var:'svDebug' = 'Y';


// Setting variables
Var:'ULpath' = '/upload/';
Var:'Process' = string;
Var:'Process'=(Action_Param:'Process');
Var:'vError'=(Action_Param:'Error');
Var:'vOption'=(Action_Param:'Option');

'<div align="center">\n';

// Checking if logged in
If: (Var:'svPost_Name1') != '';
	// Checking if form submit
	If: (Var:'Process') != '1';
	?>
		<form enctype="multipart/form-data" action="upload_memberphoto.lasso" method="post">
			<table border="0" cellpadding="2" cellspacing="2" width="400">
				<tr> 
					<td>
						<h2>Upload Member Photo</h2>
					</td>
				</tr>
				<tr> 
					<td>
						<p>Click "Browse" to select a photo to upload.</p>
					</td>
				</tr>
				<tr> 
					<td bgcolor="[Var:'svSearchContentColor']" valign="middle"> 
						<div align="center">
							<strong>Image to Upload</strong>
							<input name="one" type="file">
						</div>
					</td>
				</tr>
				<tr>
					<td valign="top">
						<div align="center">
							<input type="hidden" name="Process" value="1">
							<input type="hidden" name="ID" value="[$svMemberID]">
							<input type="submit" value="Upload">
						</div>
					</td>
				</tr>
			</table>
		</form>
		
	<?LassoScript
	// Upload form submitted, now do the process
	Else;
		
		// PROCESS THE UPLOAD
		Include:($svLibsPath)'process_uploadMPhoto.inc';
	
		If: (Error_CurrentError)!=(Error_NoError);
			Var:'vError'='5033';
		Else;
			Var:'vError' = '5061';
			Var:'vOption' = (#NewFileName);
		/If;
		Debug;
			'249: vError = ' $vError '<br>\r';
		/Debug;

		// Redirect to Member Profile page with error message
		Var:'URL' = ('m_update.lasso?Error='($vError));
		If: $svDebug == 'Y';
			Debug;
				'92: File_CurrentError = ' (File_CurrentError) '<br>';
				'92: URL = ' $URL '<br>\n';
				'<a href="'$URL'">' $URL '</a><br>\n';
			/Debug;
			Abort;
		Else;
			Redirect_URL: $URL;
		/If;

	/If;

// Not logged in, display login form
Else;
	Include:'includes/m_login.inc';
/If;
?></div>
</body>
</html>